<!DOCTYPE html>
<html>
	<head lang="en">
		<meta charset="UTF-8">
		<title>操作当当购物车页面</title>
		<link type="text/css" rel="stylesheet" href="../js/cartStyle.css" />
	</head>
	<body>

		<div class="content">
			<div class="logo">
				<img src="../Photo/dd_logo.jpg"><span onclick="close_plan();">关闭</span>
			</div>
			<div class="cartList" id="cartList">
				<ul>
					<li>商品图片</li>
					<li>商品信息</li>
					<li>单价</li>
					<li>数量</li>
					<li>总价</li>
					<li>操作</li>
				</ul>
				<ul>
					<li><img src="../Photo/dog.jpg"></li>
					<li>我和狗狗活下来了</li>
					<li>¥<input type="text" name="price" value="21.90"></li>
					<li><input type="button" name="minus" value="-" onclick="minus(this);"><input type="text"
							name="amount" value="1"><input type="button" name="plus" value="+" onclick="plus(this);">
					</li>
					<li id="price0">¥21.90</li>
					<li>
						<p onclick="collection();">移入收藏</p>
						<p onclick="del(this);">删除</p>
					</li>
				</ul>
				<ul>
					<li><img src="../Photo/mai.jpg"></li>
					<li>灰霾来了怎么办</li>
					<li>¥<input type="text" name="price" value="24.00"></li>
					<li><input type="button" name="minus" value="-" onclick="minus(this);"><input type="text"
							name="amount" value="1"><input type="button" name="plus" value="+" onclick="plus(this);">
					</li>
					<li id="price1">¥24.00</li>
					<li>
						<p onclick="collection();">移入收藏</p>
						<p onclick="del(this);">删除</p>
					</li>
				</ul>
				<ol>
					<li id="totalPrice">商品总计：<span></span></li>
					<li><span onclick="jiesuan(this)">结 算</span></li>
				</ol>
			</div>
		</div>
		<script type="text/javascript">
			function minus(t) {
				var s = t.nextElementSibling;
				if (s.value > 0) {
					s.value--;
				}
				var price = t.parentNode.previousElementSibling.lastElementChild.value;
				t.parentNode.nextElementSibling.innerHTML = ("￥" + parseInt(Math.round(price * s.value * 100)) / 100);
			}

			function plus(t) {
				var q = t.previousElementSibling;
				q.value++;
				var price = t.parentNode.previousElementSibling.lastElementChild.value;
				t.parentNode.nextElementSibling.innerHTML = ("￥" + parseInt(Math.round(price * q.value * 100)) / 100);
			}

			function del(t) {
				var a = t.parentNode.parentNode.parentNode;
				a.removeChild(t.parentNode.parentNode)
			}

			function jiesuan() {
				var a = document.getElementById("price0").innerText;
				var b = document.getElementById("price1").innerText;
				var c = parseFloat(a.substring(1, 6)) + parseFloat(b.substring(1, 6));
				document.getElementById("totalPrice").getElementsByTagName("span")[0].innerHTML = "¥" + c;
			}
			function close_plan(){
				window.close();
			}
		</script>
	</body>
</html>
